package cn.edu.cdcas.controller;

import cn.edu.cdcas.entity.Student;
import cn.edu.cdcas.utils.Constant;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/")
public class IndexController {

    @RequestMapping("index")
    public String index(Model model, HttpSession httpSession, HttpServletResponse response) {

        Student student = (Student) httpSession.getAttribute(Constant.USER_IN_SESSION);
        if (student.getExamState() == 1 || student.getMakeUpState() == 1) {
            return "redirect:exam";
        }
        return "/index";
    }
}
